<include file="public@header" />
</head>
<body>
	<div class="wrap">
		<ul class="nav nav-tabs">
			<li><a href="{:url('TemplateHeader/index')}">表头管理</a></li>
			<li class="active"><a href="{:url('TemplateHeader/add')}">新建表头</a></li>
		</ul>
		<form method="post" class="form-horizontal js-ajax-form margin-top-20" action="{:url('TemplateHeader/toAdd')}">
			<div class="form-group">
				<label for="input-name" class="col-sm-2 control-label">表头名称<span class="form-required">*</span></label>
				<div class="col-md-6 col-sm-6">
					<input type="text" class="form-control" required  name="post[name]">
				</div>
			</div>
			<div class="form-group">
				<label for="input-name" class="col-sm-2 control-label">字段名称<span class="form-required">*</span></label>
				<div class="col-md-6 col-sm-6">
					<input type="text" class="form-control"  required name="post[content][]">
				</div>
				<div class="col-md-2 col-sm-2">
					<button type="button" class="btn btn-primary add">增加</button>
				</div>
			</div>

			<div class="form-group">
				<label for="input-name" class="col-sm-2 control-label">字段名称<span class="form-required">*</span></label>
				<div class="col-md-6 col-sm-6">
					<input type="text" class="form-control" required name="post[content][]">
				</div>
				<div class="col-md-2 col-sm-2">
					<button type="button" class="btn btn-danger">删除</button>
				</div>
			</div>
			<div class="form-group button-a">
				<div class="col-sm-offset-2 col-sm-10">
					<button type="submit" class="btn btn-primary js-ajax-submit">保存</button>
					<a class="btn btn-default" href="javascript:history.back(-1);">{:lang('BACK')}</a>
				</div>
			</div>
		</form>
	</div>
	<script src="__STATIC__/js/admin.js"></script>
	<script src="__STATIC__/js/doT.min.js"></script>

	<script type="text/x-dot-template" id="template">
		<div class="form-group">
			<label for="input-name" class="col-sm-2 control-label">字段名称<span class="form-required">*</span></label>
			<div class="col-md-6 col-sm-6">
				<input type="text" class="form-control" id="input-name" required name="post[content][]">
			</div>
			<div class="col-md-2 col-sm-2">
				<button type="button" class="btn btn-danger"">删除</button>
			</div>
		</div>
	</script>

	<script type="text/javascript">
		$(document).on("click",".add",function(){
			var Text = doT.template($('#template').text());
			$('.button-a').before(Text);
		});
		$(document).on("click",".btn-danger",function(){
			$(this).parents('.form-group').remove();
		})
	</script>
</body>
</html>